import java.sql.*;
public class Insert {
    public static void main(String[] args) throws Exception {
        Connection conn = getConn();
        Statement state = conn.createStatement();   //容器
        String sql = "insert into student values('3','Kevin','男','1467295546')";   //SQL语句
        state.executeUpdate(sql);         //将sql语句上传至数据库执行
        System.out.println("一行受到影响");
        conn.close();//关闭通道
    }
    private  static Connection getConn() {
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/test";
        String username = "root";
        String password = "bwk123";
        Connection conn = null;
        try{
            Class.forName(driver);
            conn = DriverManager.getConnection(url, username, password);
        }catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return  conn;
    }
}
